﻿// See https://aka.ms/new-console-template for more information
using Akka.Actor;
using Akka.Configuration;
using Akka.Ext.Http;

var configIni = File.ReadAllText(AppDomain.CurrentDomain.BaseDirectory + "Config.ini");
var config = ConfigurationFactory.ParseString(configIni);
var system = ActorSystem.Create("client", config); //root

var akkaClient = new AkkaHttpClient(system);
var uri = "akka.tcp://server@localhost:2552/user/test";
var req = new RequestInfo();
req.Method = RestSharp.Method.Post;
req.Url = "/api/get";
//req.Url = "/api/getjson";
//req.Url = "/api/getfile";
//req.Url = "/api/post";
//req.Url = "/api/postbody";
//req.Url = "/api/postfile";
req.Header.Add("token", "ancdefg123");
req.Cookie.Add("c", "cookiesss");
//req.Query.Add("name", "李白post");
//req.Form.Add("name", "小小form");
//req.JsonBody = "{\"id\":1}";
//req.Files.Add(new UploadFileInfo() { Name = "file", BytesData = new byte[] { 1 }, FileName = "1.jpg" });

var res = await akkaClient.ExecuteAsync(uri, req);
Console.WriteLine($"IsSuccess==>    {res.IsSuccess}");
Console.WriteLine($"ErrorMessage==> {res.ErrorMessage}");
Console.WriteLine($"Data==>         {res.Data}");
Console.WriteLine($"ContentType==>  {res.ContentType}");
Console.WriteLine($"DataBytes==>    {res.DataBytes?.Length}");
Console.WriteLine($"FileName==>     {res.FileName}");
Console.WriteLine("Hello, World!");

Console.ReadKey();